<?php defined('SYSPATH') or die('No direct script access.');

class Mailer
{
    public static function SendMail($sender,$receiver,$message, $bcc = '')
    {
        $email = Email::connect();
        $message = new Swift_Message($message['subject'],$message['message'],'text/html',"utf-8");
        
        $message->setFrom($sender);

        if (is_array($bcc))
        {
            foreach($bcc as $value)
            {
                $message->addBcc($value);
            }
        }
        else
        {
            if (!is_null($bcc) && ($bcc != ""))
            {
                $message->addBcc($bcc);
            }
        }
        
        if(is_array($receiver))
        {
            foreach($receiver as $value)
            {
                $message->addTo($value);
            }
        }
        else
        {
            if (!is_null($receiver) && ($receiver != ""))
            {
                $message->addTo ($receiver);
            }
        }
        
        return $email->send($message);
    }
}